<template>
  <div id="app">
    <BasicLayouts />
  </div>
</template>

<script setup lang="ts">
import BasicLayouts from "@/layouts/BasicLayouts.vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import ACCESS_ENUM from "@/access/accessEnum";

const router = useRouter();
const store = useStore();

router.beforeEach((to, from, next) => {
  if (to.meta?.access === ACCESS_ENUM.ADMIN) {
    if (store.state.user.userRole !== ACCESS_ENUM.ADMIN) {
      next("/noAuth");
      return;
    }
  }
  next();
});
</script>
